﻿CREATE PROCEDURE [dbo].[yaf_message_unapproved](
                @ForumID INT)
AS
    BEGIN
        SELECT   MessageID = b.MessageID,
                 UserName = Isnull(b.UserName,c.Name),
                 Posted = b.Posted,
                 Topic = a.Topic,
                 Message = b.Message
        FROM     yaf_Topic a,
                 yaf_Message b,
                 yaf_User c
        WHERE    a.ForumID = @ForumID
        AND b.TopicID = a.TopicID
        AND (b.Flags & 16) = 0
        AND (a.Flags & 8) = 0
        AND (b.Flags & 8) = 0
        AND c.UserID = b.UserID
        ORDER BY a.Posted
    END


